import time
import datetime


# 时间
def time_now():
    """
        :return: Current timestamp
    """
    return int(time.time())


def current_date(str_time=False):
    return time.strftime('%Y-%m-%d %H:%M:%S') if str_time else time.strftime('%Y-%m-%d')


def datetime_now():
    """
    :return: Returns year month day
    """
    date_time = datetime.datetime.now()
    return str(date_time.year) + '-' + str(date_time.month) + '-' + str(date_time.day)


def time_wee_hours():
    """
        :return: On the day of the morning
    """
    return int(time.mktime(datetime.date.today().timetuple()))


def time_strftime(time_text, value):
    """
        :return: The timestamp is converted to a string
    """
    return time.strftime(time_text, time.localtime(value))


def str_change_timestamp(str_time, change_time="%Y-%m-%d %H:%M:%S"):
    return int(time.mktime(time.strptime(str_time, change_time)))


def int_change_str_time(time_data):
    return datetime.datetime.utcfromtimestamp(int(time_data)).strftime("%H:%M:%S")
